#coding:utf-8
from selenium import webdriver
import requests
from yundama import identify
url = 'https://accounts.douban.com/login'

dr = webdriver.Chrome()

dr.get(url)

# 账号
el_user = dr.find_element_by_id('email')
el_user.send_keys('m17173805860@163.com')

# 密码
el_pwd = dr.find_element_by_id('password')
el_pwd.send_keys('1qaz@WSX3edc')

# 验证码元素
el_captcha = dr.find_element_by_id('captcha_image')
image_url = el_captcha.get_attribute('src')
response = requests.get(image_url)
image_data = response.content

# 调用打码平台解析
result = identify(image_data)

# 验证码输入框
el_input = dr.find_element_by_id('captcha_field')
el_input.send_keys(result)

el_sub = dr.find_element_by_xpath('//*[@id="lzform"]/div[7]/input')
el_sub.click()